#include <stdio.h>
#include <unistd.h>

int main( int agrc, char* argv[] ) {
	FILE * input;
	FILE * input2;
	FILE * output;
	char buffer[1880];
	unsigned long size;
	input = fopen(argv[1], "rb");
	input2 = fopen(argv[1], "rb");
	output = fopen(argv[2], "ab+");
	fseek( input2, 0, SEEK_END );
	size = ftell( input2 );
	fseek( input, 0, SEEK_SET);
	printf(" size is %u\n", size);
	while (1) {
		while ( ftell(input) >= size-1880 ){
			sleep(1);
			fseek( input2, 0, SEEK_END );
			size = ftell( input2 );
			printf("size :%u\n", size );
		}
		unsigned read_s = fread( buffer,1, 1880, input );
		fwrite( buffer,1, read_s, output );
		fflush(output);
		if( feof(input) ){
			clearerr(input);
		}
	}
	fclose(input);
	fclose(output);
	
	return 0;
}

 
